package com.itheima.controller;

import com.itheima.result.Result;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("sendSms")
    public Result sendSms(String telephone){
        //调用service发送验证码
        userService.sendSms(telephone);
        return Result.success();
    }

    @PostMapping("login")
    public Result login(@RequestBody Map<String,String> paramMap){
        //调用service完成登录
        String res = userService.login(paramMap);
        return Result.success(res);
    }

    @GetMapping("verify")
    //@RequestHeader:将指定请求体的值赋值给方法参数
    public Result verify(@RequestHeader("Authorization") String token){
        userService.verify(token);
        return Result.success();
    }
}
